package com.example.common.entity;

import jakarta.persistence.*;
import lombok.Data;

import java.math.BigInteger;
import java.time.LocalDateTime;

@Entity
@Table(name = "sys_quartz_job")
@Data
public class SysQuartzJob {
    @Id
    @Column(name = "job_id", nullable = false)
    private BigInteger jobId;
    
    @Column(name = "bean_name")
    private String beanName;
    
    @Column(name = "cron_expression")
    private String cronExpression;
    
    @Column(name = "is_pause")
    private Boolean isPause;
    
    @Column(name = "job_name", unique = true)
    private String jobName;
    
    @Column(name = "method_name")
    private String methodName;
    
    private String params, description;
    
    @Column(name = "person_in_charge", length = 100)
    private String personInCharge;
    
    @Column(length = 100)
    private String email;
    
    @Column(name = "sub_task", length = 100)
    private String subTask;
    
    @Column(name = "pause_after_failure")
    private Boolean pauseAfterFailure;
    
    // create_by
    @ManyToOne
    @JoinColumn(name = "create_by", referencedColumnName = "username")
    private SysUser creator;
    
    // update_by
    @ManyToOne
    @JoinColumn(name = "update_by", referencedColumnName = "username")
    private SysUser updator;
    
    @Column(name = "create_time")
    private LocalDateTime createTime;
    
    @Column(name = "update_time")
    private LocalDateTime updateTime;
    
    public BigInteger getJobId() {
        return jobId;
    }
    
    public void setJobId(BigInteger jobId) {
        this.jobId = jobId;
    }
    
    public String getBeanName() {
        return beanName;
    }
    
    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }
    
    public String getCronExpression() {
        return cronExpression;
    }
    
    public void setCronExpression(String cronExpression) {
        this.cronExpression = cronExpression;
    }
    
    public String getJobName() {
        return jobName;
    }
    
    public void setJobName(String jobName) {
        this.jobName = jobName;
    }
    
    public String getMethodName() {
        return methodName;
    }
    
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }
    
    public String getParams() {
        return params;
    }
    
    public void setParams(String params) {
        this.params = params;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    @Transient
    public String getCreateBy() {
        return creator.getUsername();
    }
    
    public void setCreateBy(String createBy) {
        SysUser user = new SysUser();
        user.setUsername(createBy);
        this.creator = user;
    }
    
    @Transient
    public String getUpdateBy() {
        return updator.getUsername();
    }
    
    public void setUpdateBy(String updateBy) {
        SysUser user = new SysUser();
        user.setUsername(updateBy);
        this.updator = user;
    }
    
    public Boolean getIsPause() {
        return isPause;
    }
    
    public void setIsPause(Boolean isPause) {
        this.isPause = isPause;
    }
    
    public Boolean getPauseAfterFailure() {
        return pauseAfterFailure;
    }
    
    public void setPauseAfterFailure(Boolean pauseAfterFailure) {
        this.pauseAfterFailure = pauseAfterFailure;
    }
    
    public String getPersonInCharge() {
        return personInCharge;
    }
    
    public void setPersonInCharge(String personInCharge) {
        this.personInCharge = personInCharge;
    }
    
    public String getEmail() {
        return email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    public String getSubTask() {
        return subTask;
    }
    
    public void setSubTask(String subTask) {
        this.subTask = subTask;
    }
    
    public LocalDateTime getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
    
    public LocalDateTime getUpdateTime() {
        return updateTime;
    }
    
    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }
}
